/*
Brick And Blast, a crossplatform breakout game.
 Copyright (C) 2008-2010 Julien CLEMENT (andematunum@gmail.com)
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
 as published by the Free Software Foundation; either version 2
 of the License, or (at your option) any later version.
 
 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 

*/

#ifndef _Bumper_h_
#define _Bumper_h_

/**
* file   Bumper.h
* date   Sam 2 jan 2010 20:05:43 CET
* brief  TODO
*/

#include "SDL.h"
#include "GameObject.h"

#define BOUNCE_AMPLITUDE (8) //(6)
#define BOUNCE_SPEED (10) //(16)
#define BOUNCE_ATTENUATION (300) //(256)

class Bumper: public GameObject {
public:
  Bumper(SDL_Point& position,
         SDL_TextureID texture)
    : GameObject(GAME_OBJECT_BUMPER,GAME_OBJECT_CIRCLE,position,texture) {
    set_position(position);
  }
  virtual bool update ();
  virtual void handle_collision(GameObject* obj, const ColliderData& data) {
    if (obj->get_type() == GAME_OBJECT_BALL) {
      bounce_start_ = SDL_GetTicks();
      // Prevent the bumper from beeing blocked
      // with a bad size.
      if (!bounce_) {
        size_init_ = size_.r;
        bounce_ = true;
      }
    }
  }

private:
  Uint32 bounce_start_;
  bool bounce_;
  int size_init_;
};

#endif

